package com.sealer.pattern.structural.facade.facade;

import com.sealer.pattern.structural.facade.model.Address;
import com.sealer.pattern.structural.facade.model.Customer;
import com.sealer.pattern.structural.facade.service.AddressService;
import com.sealer.pattern.structural.facade.service.CustomerService;

/**
 * Created by sealer on 17/04/04.
 */
public class AddressFacade {
    private CustomerService customerService;

    private AddressService addressService;

    public void updateAddressStreet(Long customerId, String street) {
        if (customerService == null) {
            customerService = new CustomerService();
        }

        if (addressService == null) {
            addressService = new AddressService();
        }

        Customer customer = customerService.findById(customerId);
        Address address = customer.getAddress();
        address.setStreet(street);
        addressService.save(address);
    }

    public void updateAddressCity(Long customerId, String city) {
        if (customerService == null) {
            customerService = new CustomerService();
        }

        if (addressService == null) {
            addressService = new AddressService();
        }

        Customer customer = customerService.findById(customerId);
        Address address = customer.getAddress();
        address.setCity(city);
        addressService.save(address);
    }
}
